package com.cq.hd.admin.controller;

import com.cq.hd.common.enums.ExceptionEnum;
import com.cq.hd.common.response.ResultGenerator;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author: mYunYu
 * @date: 2020/12/23 9:08
 * @version: v1.0
 */
@ApiIgnore
@RestController
public class UnauthorizedController {

    @RequestMapping(path = "/unauthorized/{message}")
    public Object unauthorized(@PathVariable String message) {
        Object result;
        if (ExceptionEnum.UNAUTHORIZED.getMsg().equals(message)) {
            result = ResultGenerator.error(507, message);
        } else if (ExceptionEnum.AUTH_TIME_OUT.getMsg().equals(message)) {
            result = ResultGenerator.error(501, message);
        } else {
            result = ResultGenerator.error(506, message);
        }
        return result;
    }

}
